package co.fitstart.entity.courseware.dietary;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Type;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import co.fitstart.entity.courseware.fitnessgroup.BatchCourseware;

/**
 * 周计划-饮食
 * @author haiyan_xiao
 *
 */
@Entity
@Table(name = "dietary")
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class Dietary {
    @Id
    @GeneratedValue
    private Long id;
    
    /** 所属课件批次 */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JSONField(serialize = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private BatchCourseware batch;
    
    /** 早餐模板 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JSONField(serialize = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    @JsonInclude(Include.NON_NULL)
    private DietaryProgramTemplate breakfastTemplate;
    
    /** 早餐描述 */
    @Type(type = "text")
    @JSONField(serialize = false)
    private String breakfastDescription;
    
    /** 早餐加餐模板 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JSONField(serialize = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    @JsonInclude(Include.NON_NULL)
    private DietaryProgramTemplate breakfastSnackTemplate;
    
    /** 早餐加餐描述 */
    @Type(type = "text")
    @JSONField(serialize = false)
    private String breakfastSnackDescription;
    
    /** 午餐模板 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JSONField(serialize = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    @JsonInclude(Include.NON_NULL)
    private DietaryProgramTemplate lunchTemplate;
    
    /** 午餐描述 */
    @Type(type = "text")
    @JSONField(serialize = false)
    private String lunchDescription;
    
    /** 午餐加餐模板 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JSONField(serialize = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    @JsonInclude(Include.NON_NULL)
    private DietaryProgramTemplate lunchSnackTemplate;
    
    /** 午餐加餐描述 */
    @Type(type = "text")
    @JSONField(serialize = false)
    private String lunchSnackDescription;
    
    /** 晚餐模板 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JSONField(serialize = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    @JsonInclude(Include.NON_NULL)
    private DietaryProgramTemplate dinnerTemplate;
    
    /** 晚餐描述 */
    @Type(type = "text")
    @JSONField(serialize = false)
    private String dinnerDescription;
    
    /** 晚餐加餐模板 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JSONField(serialize = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    @JsonInclude(Include.NON_NULL)
    private DietaryProgramTemplate dinnerSnackTemplate;
    
    /** 晚餐加餐描述 */
    @Type(type = "text")
    @JSONField(serialize = false)
    private String dinnerSnackDescription;
    
    /** 饮水量 */
    private String waterIntake;
    
    /** 备注 */
    private String remark;
    
    private Date createTime;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    public Dietary() {
        
    }
    
    public Dietary(BatchCourseware batch) {
        this.batch = batch;
        this.createTime = new Date();
        this.disabled = false;
    }
    
    /**
     * edit
     * @param breakfastTemplate
     * @param breakfastDescription
     * @param breakfastSnackTemplate
     * @param breakfastSnackDescription
     * @param lunchTemplate
     * @param lunchDescription
     * @param lunchSnackTemplate
     * @param lunchSnackDescription
     * @param dinnerTemplate
     * @param dinnerDescription
     * @param dinnerSnackTemplate
     * @param dinnerSnackDescription
     * @param waterIntake
     * @param remark
     * @return
     */
    public Dietary edit(DietaryProgramTemplate breakfastTemplate,String breakfastDescription,
            DietaryProgramTemplate breakfastSnackTemplate, String breakfastSnackDescription,
            DietaryProgramTemplate lunchTemplate, String lunchDescription,
            DietaryProgramTemplate lunchSnackTemplate, String lunchSnackDescription,
            DietaryProgramTemplate dinnerTemplate, String dinnerDescription,
            DietaryProgramTemplate dinnerSnackTemplate, String dinnerSnackDescription,
            String waterIntake, String remark) {
        this.breakfastTemplate = breakfastTemplate;
        this.breakfastDescription = breakfastDescription;
        this.breakfastSnackTemplate = breakfastSnackTemplate;
        this.breakfastSnackDescription = breakfastSnackDescription;
        this.lunchTemplate = lunchTemplate;
        this.lunchDescription = lunchDescription;
        this.lunchSnackTemplate = lunchSnackTemplate;
        this.lunchSnackDescription = lunchSnackDescription;
        this.dinnerTemplate = dinnerTemplate;
        this.dinnerDescription = dinnerDescription;
        this.dinnerSnackTemplate = dinnerSnackTemplate;
        this.dinnerSnackDescription = dinnerSnackDescription;
        this.waterIntake = waterIntake;
        this.remark = remark;
        
        return this;
    }

    /**
     * 
     * @return
     */
    public Dietary disable() {
        this.disabled = true;
        return this;
    }

    /**
     * 
     * @return
     */
    public String getBreakfastTemplateName() {
        return this.breakfastTemplate == null ? null : this.breakfastTemplate.getName();
    }

    /**
     * 
     * @return
     */
    public String getBreakfastSnackTemplateName() {
        return this.breakfastSnackTemplate == null ? null : this.breakfastSnackTemplate.getName();
    }

    /**
     * 
     * @return
     */
    public String getLunchTemplateName() {
        return this.lunchTemplate == null ? null : this.lunchTemplate.getName();
    }

    /**
     * 
     * @return
     */
    public String getLunchSnackTemplateName() {
        return this.lunchSnackTemplate == null ? null : this.lunchSnackTemplate.getName();
    }

    /**
     * 
     * @return
     */
    public String getDinnerTemplateName() {
        return this.dinnerTemplate == null ? null : this.dinnerTemplate.getName();
    }

    /**
     * 
     * @return
     */
    public String getDinnerSnackTemplateName() {
        return this.dinnerSnackTemplate == null ? null : this.dinnerSnackTemplate.getName();
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the batch
     */
    public BatchCourseware getBatch() {
        return batch;
    }

    /**
     * @return the breakfastTemplate
     */
    public DietaryProgramTemplate getBreakfastTemplate() {
        return breakfastTemplate;
    }

    /**
     * @return the breakfastDescription
     */
    public String getBreakfastDescription() {
        return breakfastDescription;
    }

    /**
     * @return the breakfastSnackTemplate
     */
    public DietaryProgramTemplate getBreakfastSnackTemplate() {
        return breakfastSnackTemplate;
    }

    /**
     * @return the breakfastSnackDescription
     */
    public String getBreakfastSnackDescription() {
        return breakfastSnackDescription;
    }

    /**
     * @return the lunchTemplate
     */
    public DietaryProgramTemplate getLunchTemplate() {
        return lunchTemplate;
    }

    /**
     * @return the lunchDescription
     */
    public String getLunchDescription() {
        return lunchDescription;
    }

    /**
     * @return the lunchSnackTemplate
     */
    public DietaryProgramTemplate getLunchSnackTemplate() {
        return lunchSnackTemplate;
    }

    /**
     * @return the lunchSnackDescription
     */
    public String getLunchSnackDescription() {
        return lunchSnackDescription;
    }

    /**
     * @return the dinnerTemplate
     */
    public DietaryProgramTemplate getDinnerTemplate() {
        return dinnerTemplate;
    }

    /**
     * @return the dinnerDescription
     */
    public String getDinnerDescription() {
        return dinnerDescription;
    }

    /**
     * @return the dinnerSnackTemplate
     */
    public DietaryProgramTemplate getDinnerSnackTemplate() {
        return dinnerSnackTemplate;
    }

    /**
     * @return the dinnerSnackDescription
     */
    public String getDinnerSnackDescription() {
        return dinnerSnackDescription;
    }

    /**
     * @return the waterIntake
     */
    public String getWaterIntake() {
        return waterIntake;
    }

    /**
     * @return the remark
     */
    public String getRemark() {
        return remark;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param batch the batch to set
     */
    public void setBatch(BatchCourseware batch) {
        this.batch = batch;
    }

    /**
     * @param breakfastTemplate the breakfastTemplate to set
     */
    public void setBreakfastTemplate(DietaryProgramTemplate breakfastTemplate) {
        this.breakfastTemplate = breakfastTemplate;
    }

    /**
     * @param breakfastDescription the breakfastDescription to set
     */
    public void setBreakfastDescription(String breakfastDescription) {
        this.breakfastDescription = breakfastDescription;
    }

    /**
     * @param breakfastSnackTemplate the breakfastSnackTemplate to set
     */
    public void setBreakfastSnackTemplate(DietaryProgramTemplate breakfastSnackTemplate) {
        this.breakfastSnackTemplate = breakfastSnackTemplate;
    }

    /**
     * @param breakfastSnackDescription the breakfastSnackDescription to set
     */
    public void setBreakfastSnackDescription(String breakfastSnackDescription) {
        this.breakfastSnackDescription = breakfastSnackDescription;
    }

    /**
     * @param lunchTemplate the lunchTemplate to set
     */
    public void setLunchTemplate(DietaryProgramTemplate lunchTemplate) {
        this.lunchTemplate = lunchTemplate;
    }

    /**
     * @param lunchDescription the lunchDescription to set
     */
    public void setLunchDescription(String lunchDescription) {
        this.lunchDescription = lunchDescription;
    }

    /**
     * @param lunchSnackTemplate the lunchSnackTemplate to set
     */
    public void setLunchSnackTemplate(DietaryProgramTemplate lunchSnackTemplate) {
        this.lunchSnackTemplate = lunchSnackTemplate;
    }

    /**
     * @param lunchSnackDescription the lunchSnackDescription to set
     */
    public void setLunchSnackDescription(String lunchSnackDescription) {
        this.lunchSnackDescription = lunchSnackDescription;
    }

    /**
     * @param dinnerTemplate the dinnerTemplate to set
     */
    public void setDinnerTemplate(DietaryProgramTemplate dinnerTemplate) {
        this.dinnerTemplate = dinnerTemplate;
    }

    /**
     * @param dinnerDescription the dinnerDescription to set
     */
    public void setDinnerDescription(String dinnerDescription) {
        this.dinnerDescription = dinnerDescription;
    }

    /**
     * @param dinnerSnackTemplate the dinnerSnackTemplate to set
     */
    public void setDinnerSnackTemplate(DietaryProgramTemplate dinnerSnackTemplate) {
        this.dinnerSnackTemplate = dinnerSnackTemplate;
    }

    /**
     * @param dinnerSnackDescription the dinnerSnackDescription to set
     */
    public void setDinnerSnackDescription(String dinnerSnackDescription) {
        this.dinnerSnackDescription = dinnerSnackDescription;
    }

    /**
     * @param waterIntake the waterIntake to set
     */
    public void setWaterIntake(String waterIntake) {
        this.waterIntake = waterIntake;
    }

    /**
     * @param remark the remark to set
     */
    public void setRemark(String remark) {
        this.remark = remark;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }
}
